<?php 
		$username = $_SESSION['username'];        $query = "select * from user where username='$username'";        $result = mysql_query($query);
		if (!$result) {  			echo '<script>					<!-- 							 window.location= "http://www.mariokartchallenger.com"							//-->					</script>'; die();		}
		$user = mysql_fetch_array($result);
		$temp = $user['nick']; 
		$gamecode = $user['gamecode']; 
		if (empty($gamecode)) { include 'gamecode.php'; exit();};
?>

<table height="320px" width="603px">
				<tr><td id="info" valign="top">
					<table cellpadding="0" cellspacing="0" >
						<tr><td width="395px" valign="top"><?php include 'navbar.php' ?></td>
						<td>&nbsp;</td>
						<td valign="top">
							<table cellpadding="0" cellspacing="0" border="0" align="right" width="185px"><tr><td>
							<?php if (empty($temp)) { include 'guestgreet.php'; } else{ include 'usergreet.php'; } ?>
							</td></tr><tr><td id="login"><div align="right"><span style="font-size:12px"><? echo $user['nick']; ?></span> ( <strong><?php if (is_authed()) { echo '<a href="index.php?act=logout">Logout</a>';} else {echo '<a href="register.php">Register</a> | <a href="index.php">Log In</a> ';} ?> </strong> )</div></td></tr></table>
					

						</td></tr>
					</table>

					<table cellpadding="0" cellspacing="0">
						<tr><td width="325px" height="250px" valign="top"> 
							<div align="right" id="gameinfo">	
								<table cellpadding="0" cellspacing="0" border="0" width="385px">
									<tr><td>
										<table cellpadding="0" cellspacing="0" border="0">
											<tr><td align="left">
												<img src="img/earth.png" />
											</td></tr>
										</table>
									</td><td align="right">
										<table cellpadding="0" cellspacing="0" border="0">
											<tr><td align="right" style="padding-right : 5px" valign="top">
												<span style="font-size:16px">Matchmaking Center</span>
											</td></tr>
											<tr><td align="right" style="padding-right : 5px" valign="top">
												<span style="font-size:10px">start your own room or join another</span>
											</td></tr>
										</table>
									</td></tr>
								</table>
								<p>
								
								<table cellpadding="0" cellspacing="0" border="0" width="385px">
									<tr><td align="right" width="50%" valign="top">
										<table cellpadding="0" cellspacing="0" border="0">
											<tr><td align="right" valign="top">
												<span style="font-size:10px; color:black"><strong>new members:</strong><span><br />
											</td></tr>
											<tr><td align="right" valign="top">
												<?php 						 
													$count = '0';          											$query = "select * from user order by userid desc LIMIT 18";				    	     						$newusers = mysql_query($query);
					
													while($listem = mysql_fetch_array($newusers)){
										        	echo '<span style="font-size:10px"><strong><a href="index.php?showuser=', $listem[userid], '">',$listem[nick],'</a>'; 													if ($count != '17') {echo "</strong></span>, &nbsp;";} else {echo "</strong></span>&nbsp;";}
													$count++;													}
												?>
											</td></tr>
										</table>
									</td><td align="right" width="50%" valign="top">
										<table cellpadding="0" cellspacing="0" border="0">
											<tr><td align="right" style="padding-right : 5px" valign="top">
												<span style="font-size:10px; color:black"><strong>recently created:</strong></span><br />
											</td></tr>
											<tr><td align="right" style="padding-right : 5px" valign="top">
												<?php 						 
								          											$query = "select * from gamematch order by id desc LIMIT 5";				    	     						$battle = mysql_query($query);
					
													while($gamematch = mysql_fetch_array($battle)){
										        	echo '<span style="font-size:10px"><strong><a href="index.php?showroom=', $gamematch['id'], '">',$gamematch['battlename'],'</a>'; 													echo "</strong></span><br />";													}
												?>
												<p>
											</td></tr>
											<tr><td align="right" style="padding-right : 5px" valign="top">
												<span style="font-size:10px; color:black"><strong>starting soon:<br /></span>
											</td></tr>
											<tr><td align="right" style="padding-right : 5px" valign="top">
												<?php 						 
							
													$todays_date = date("F j, Y"); 
													$querytime = date("G") + 1 . ':00';
													if ($querytime > 23) {$querytime = "0:00";}
							          											$query = "select * from gamematch where matchtime='$querytime' order by matchtime desc";         											$battle = mysql_query($query);

													while($gamematch = mysql_fetch_array($battle)){
														$oldtime = $gamematch['matchtime'];
														$cleantime = date("gA", strtotime($oldtime));
											        	if ($gamematch['matchdate']==$todays_date) {echo '<span style="font-size:10px"><strong><a href="index.php?showroom=', $gamematch['id'], '">',$gamematch['battlename'],'</a>'; echo "</strong></span><br />";}
																											}
							
												?>
											</td></tr>
										</table>
									</td></tr>
								</table>
								
								
								

								
								<br /> <!-- Current time is <?php $goodtime = date("H:i:s", time());echo date("g:i a", strtotime($goodtime)); ?> (CDT)</strong> -->
								</span>
					</div>
					</td><td valign="top">
                          <div align="right">
							<?php
                            if (is_authed()) { include 'sidebar.php';} elseif (!is_authed()) { echo '' ;} ?>						</div>
					</td>

					</tr></table>
				
					</td></tr>
			</table>
			</td>
		</tr>
	</table>

<?php include 'footer.php' ?>
